package demo3;

import demo1.Book;
import demo1.BookList;

import java.util.Scanner;

public class Find implements Operation{
    @Override
    public void work(BookList book) {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入要查找的图书的名字");
        String name=sc.nextLine();
        int currentSize=book.getSize();
        for (int i = 0; i <currentSize ; i++) {
            Book book1=book.getBook(i);
            if(book1.getName().equals(name)){
                System.out.println("找到了");
                System.out.println(book.getBook(i).toString());
                return;
            }
        }
        System.out.println("没找到");
    }
}